package com.wfh.rpc.server;

import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import lombok.extern.slf4j.Slf4j;

/**
 * @Title: VertxHttpServer
 * @Author wangfenghuan
 * @Package main.java.com.wfh.rpc.server
 * @Date 2025/10/12 12:02
 * @description: 服务器
 */
@Slf4j
public class VertxHttpServer implements Server{
    @Override
    public void doStart(int port) {
        // 创建vertx实例
        Vertx vertx = Vertx.vertx();
        // 创建http服务器
        HttpServer httpServer = vertx.createHttpServer();
        httpServer.requestHandler(new HttpServerHandler());
        // 启动http服务器并监听端口
        httpServer.listen(port, result -> {
            if (result.succeeded()){
                log.info("Server is listening on port: {}", port);
            }else{
                log.info("Server start failed");
            }

        });
    }
}
